//
//  WYJDoctorDetailViewController.m
//  QuickCure
//
//  Created by believewilliam on 16/9/13.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "WYJDoctorDetailViewController.h"
#import <Masonry.h>
#import "DoctorApplyViewController.h"

@interface WYJDoctorDetailViewController ()

@end

@implementation WYJDoctorDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self setupUI];
    
}
// 布局UI
- (void)setupUI {
    // 1.布局“病人信息”view
    UIView *patientView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 90)];
    [self.view addSubview:patientView];
    // 1.1添加imagView
    UIImageView *imgView = [[UIImageView alloc] init];
    imgView.image = [UIImage imageNamed:@"banner"];
    [patientView addSubview:imgView];
    [imgView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(patientView).offset(10);
        make.left.equalTo(patientView).offset(10);
        make.bottom.equalTo(patientView).offset(-10);
        make.width.equalTo(patientView.frame.size.height - 20);
    }];

    // 1.2添加lab_name
    UILabel *lab_name = [[UILabel alloc] init];
    [patientView addSubview:lab_name];
    lab_name.text = self.model.name;
    [lab_name makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(patientView).offset(20);
        make.left.equalTo(imgView.mas_right).offset(10);
    }];
    // 1.3添加lab_disease
    UILabel *lab_disease =[[UILabel alloc] init];
    [patientView addSubview:lab_disease];
    lab_disease.text = self.model.disease;
    lab_disease.font = [UIFont systemFontOfSize:15];
    lab_disease.textColor = [UIColor grayColor];
    [lab_disease makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(patientView).offset(20);
        make.left.equalTo(lab_name.mas_right).offset(10);
    }];
    // 1.4添加lab_time
    UILabel *lab_time = [[UILabel alloc] init];
    [patientView addSubview:lab_time];
    lab_time.text = self.model.time;
    lab_time.font = [UIFont systemFontOfSize:15];
    lab_time.textColor = [UIColor grayColor];
    [lab_time makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lab_name.bottom).offset(15);
        make.left.equalTo(lab_name);
    }];
    // 1.5添加btn_status
    UIButton *btn_status = [[UIButton alloc] init];
    [patientView addSubview:btn_status];
    btn_status.backgroundColor = kThemeColor;
    [btn_status setTitle:self.model.status forState:UIControlStateNormal];
    [btn_status setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn_status mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(patientView).offset(15);
        make.right.equalTo(patientView).offset(-15);
        make.width.equalTo(patientView.frame.size.height - 30);
        make.bottom.equalTo(patientView).offset(-15);
        
    }];
    btn_status.layer.cornerRadius = 30;
    // 1.6添加分割线
    UIView *line1 = [[UIView alloc] initWithFrame:CGRectMake(0, patientView.frame.size.height - 1, patientView.frame.size.width, 1)];
    [patientView addSubview:line1];
    line1.backgroundColor = [UIColor grayColor];
    
    // 2.布局 “预约医生"view
    UIView *applyView = [[UIView alloc] initWithFrame:CGRectMake(0, patientView.frame.size.height, self.view.frame.size.width, 40)];
    [self.view addSubview:applyView];
        // 2.1添加“预约医生"label
    UILabel *lab_apply = [[UILabel alloc] init];
    [applyView addSubview:lab_apply];
    lab_apply.text = @"预约医生：";
    lab_apply.textColor = [UIColor grayColor];
    [lab_apply makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(applyView);
        make.left.equalTo(applyView).offset(15);
    }];
    // 2.2添加分割线
    UIView *line2 = [[UIView alloc] initWithFrame:CGRectMake(0, applyView.frame.size.height - 1, applyView.frame.size.width, 1)];
    [applyView addSubview:line2];
    line2.backgroundColor = [UIColor grayColor];
    
    // 3.布局 医生信息 view
    UIView *doctorView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(applyView.frame), self.view.frame.size.width, 80)];
    [self.view addSubview:doctorView];
    // 3.1添加lab_doctor
    UILabel *lab_doctor = [[UILabel alloc] init];
    [doctorView addSubview:lab_doctor];
    lab_doctor.text = self.model.doctor;
    [lab_doctor makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(doctorView).offset(15);
        make.centerY.equalTo(doctorView).offset(-15);
    }];
    // 3.2添加lab_rank
    UILabel *lab_rank = [[UILabel alloc] init];
    [doctorView addSubview:lab_rank];
    lab_rank.text = self.model.rank;
    lab_rank.textColor = [UIColor grayColor];
    [lab_rank makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab_doctor.mas_right).offset(20);
        make.centerY.equalTo(lab_doctor);
    }];
    // 3.3添加lab_hospital
    UILabel *lab_hospital = [[UILabel alloc] init];
    [doctorView addSubview:lab_hospital];
    lab_hospital.text = self.model.hospital;
    lab_hospital.textColor = [UIColor grayColor];
    [lab_hospital makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(doctorView).offset(15);
        make.centerY.equalTo(doctorView).offset(15);
    }];
    // 3.4添加btn_suggest
    UIButton *btn_suggest = [[UIButton alloc] init];
    [doctorView addSubview:btn_suggest];
    [btn_suggest setBackgroundImage:[UIImage imageNamed:@"dijiaofankui"] forState:UIControlStateNormal];
    [btn_suggest sizeToFit];
    [btn_suggest makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(doctorView);
        make.right.equalTo(doctorView).offset(-15);
    }];
    // 3.5添加分割线
    UIView *line3 = [[UIView alloc] initWithFrame:CGRectMake(0, doctorView.frame.size.height - 1, doctorView.frame.size.width, 1)];
    [doctorView addSubview:line3];
    line3.backgroundColor = [UIColor grayColor];
    
    // 4.布局 “预约信息"view
    UIView *applyInfoView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(doctorView.frame), self.view.frame.size.width, 40)];
    [self.view addSubview:applyInfoView];
    // 4.1添加“预约须知"label
    UILabel *lab_applyInfo = [[UILabel alloc] init];
    [applyInfoView addSubview:lab_applyInfo];
    lab_applyInfo.text = @"预约须知：";
    lab_applyInfo.textColor = [UIColor grayColor];
    [lab_applyInfo makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(applyInfoView);
        make.left.equalTo(applyInfoView).offset(15);
    }];
    // 4.2添加分割线
    UIView *line4 = [[UIView alloc] initWithFrame:CGRectMake(0, applyInfoView.frame.size.height - 1, applyInfoView.frame.size.width, 1)];
    [applyInfoView addSubview:line4];
    line4.backgroundColor = [UIColor grayColor];
    
    // 5.布局 “预约具体信息"view
    UIView *applyDetailView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(applyInfoView.frame), self.view.frame.size.width, 120)];
    [self.view addSubview:applyDetailView];
    // 5.1添加“就诊地点："label
    UILabel *lab_location = [[UILabel alloc] init];
    [applyDetailView addSubview:lab_location];
    lab_location.text = @"就诊地点：";
    [lab_location makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(applyDetailView).offset(-30);
        make.left.equalTo(applyView).offset(15);
    }];
    // 5.2添加“取号时间："label
    UILabel *lab_pickTime = [[UILabel alloc] init];
    [applyDetailView addSubview:lab_pickTime];
    lab_pickTime.text = @"取号时间：";
    [lab_pickTime makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(applyDetailView);
        make.left.equalTo(applyView).offset(15);
    }];
    // 5.3添加“取号地址："label
    UILabel *lab_pickAddress = [[UILabel alloc] init];
    [applyDetailView addSubview:lab_pickAddress];
    lab_pickAddress.text = @"取号地址：";
    [lab_pickAddress makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(applyDetailView).offset(30);
        make.left.equalTo(applyView).offset(15);
    }];
    // 5.4添加“就诊地点："label的内容
    UILabel *lab_locationContent = [[UILabel alloc] init];
    [applyDetailView addSubview:lab_locationContent];
    lab_locationContent.text = self.model.location;
    lab_locationContent.font = [UIFont systemFontOfSize:14];
    lab_locationContent.textColor = [UIColor grayColor];
    [lab_locationContent makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(applyDetailView).offset(-30);
        make.left.equalTo(lab_location.mas_right).offset(0);
    }];
    // 5.5添加“取号时间："label的内容
    UILabel *lab_pickTimeContent = [[UILabel alloc] init];
    [applyDetailView addSubview:lab_pickTimeContent];
    lab_pickTimeContent.text = self.model.pickTime;
    lab_pickTimeContent.font = [UIFont systemFontOfSize:14];
    lab_pickTimeContent.textColor = [UIColor grayColor];
    [lab_pickTimeContent makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(applyDetailView);
        make.left.equalTo(lab_pickTime.mas_right).offset(0);
    }];
    // 5.6添加“取号地址："label的内容
    UILabel *lab_pickAddressContent = [[UILabel alloc] init];
    [applyDetailView addSubview:lab_pickAddressContent];
    lab_pickAddressContent.text = self.model.pickAddress;
    lab_pickAddressContent.font = [UIFont systemFontOfSize:14];
    lab_pickAddressContent.textColor = [UIColor grayColor];
    [lab_pickAddressContent makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(applyDetailView).offset(30);
        make.left.equalTo(lab_pickAddress.mas_right).offset(0);
    }];
    // 5.7添加分割线
    UIView *line5 = [[UIView alloc] initWithFrame:CGRectMake(0, applyDetailView.frame.size.height - 1, applyDetailView.frame.size.width, 1)];
    [applyDetailView addSubview:line5];
    line5.backgroundColor = [UIColor grayColor];
    
    // 6.布局底部两个button所在的view
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(applyDetailView.frame), self.view.frame.size.width, self.view.frame.size.height - CGRectGetMaxY(applyDetailView.frame) - 64)];
    [self.view addSubview:bottomView];
    // 6.1添加“短信重发”button
    UIButton *btn_sendMesg = [[UIButton alloc] init];
    [bottomView addSubview:btn_sendMesg];
    [btn_sendMesg setTitle:@"短信重发" forState:UIControlStateNormal];
    [btn_sendMesg setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [btn_sendMesg setBackgroundImage:[UIImage imageNamed:@"link_button_02"] forState:UIControlStateNormal];
    [btn_sendMesg makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bottomView).offset(40);
        make.bottom.equalTo(bottomView).offset(-10);
        make.width.equalTo(110);
        make.height.equalTo(40);
        
    }];
    
    // 6.2添加“取消预约”button
    UIButton *btn_cancel = [[UIButton alloc] init];
    [bottomView addSubview:btn_cancel];
    [btn_cancel setTitle:@"取消预约" forState:UIControlStateNormal];
    [btn_cancel setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [btn_cancel setBackgroundImage:[UIImage imageNamed:@"link_button_02"] forState:UIControlStateNormal];
    [btn_cancel makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(bottomView).offset(-40);
        make.bottom.equalTo(bottomView).offset(-10);
        make.width.equalTo(110);
        make.height.equalTo(40);
    }];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
